<%@ page language="java" contentType="text/html; charset=UTF-8"
    import="java.util.*,java.text.*,kk.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">


<html>
  <head>
    <%--<base href="<%=basePath--%>">--%>
    
    <title>My JSP 'addcomments.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
  <%@include file="checklogin.jsp" %>
    <%
    	  request.setCharacterEncoding("utf-8");
    	  String id=request.getParameter("nid");
    	  Date date = new Date(System.currentTimeMillis());
		  SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		  String d=dateFormat.format(date);
    	  Long cnid=Long.parseLong(id);
          String user=request.getParameter("cauthor");
          out.print(user);
          out.print(d);
          String ip=request.getParameter("cip");
          out.print(ip);
          String neirong=request.getParameter("ccontent");
          Comment c=new Comment();			
          CommentDao cdao=new  CommentDao();
          c.setCnid(cnid);
          c.setCauthor(user);
          c.setCip(ip);
          c.setCcontent(neirong);
          c.setCdate(d);
          int i = cdao.add(c);
          //if(i!=0)
          //out.print("<script>alert('增加评论成功！');history.back();</script>");
          //else if(i==0)
          // out.print("<script>alert('增加评论失败！');history.back();</script>");
         //out.print("<script>alert('用户名或者密码错误');history.back();</script>");
         //session.setAttribute("USER_LOGIN", stu);//学生信息存入session
         //session.setAttribute("xuehao", stuno);
         //request.getRequestDispatcher("chakan.jsp").forward(request, response);
    %>
  </body>
</html>
